package com.seuic.hnjiningposapp.hnapps.util;

import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Matrix;
import android.util.Base64;

import com.blankj.utilcode.util.SPStaticUtils;
import com.seuic.hnjiningposapp.hnapps.bean.AllDealBean;
import com.seuic.hnjiningposapp.hnapps.bean.DqBean;
import com.seuic.hnjiningposapp.hnapps.bean.HqBean;
import com.seuic.hnjiningposapp.hnapps.bean.LlBean;
import com.seuic.hnjiningposapp.hnapps.bean.SpBean;
import com.seuic.hnjiningposapp.hnapps.bean.StatisticsBean;
import com.seuic.hnjiningposapp.hnapps.bean.ZzhBean;
import com.seuic.posdsdk.pos_func.PosCallbacks;
import com.seuic.posdsdk.pos_func.PosFuncs;
import com.socks.library.KLog;

import java.util.List;

/**
 * 打印
 */
public class PrintUtil {
    private static int all_num = 0;

    /**
     * 本行助农取款、电子现金圈存、本行现金汇款、他行现金汇款
     * <p>
     * 打印回执单
     * time 时间
     * ccsno 凭证序号
     * termno 终端号
     * manager 经理号
     * make_type 交易名称
     * runningwaterNo 流水号
     * noName 账户名称
     * cardNo 卡号
     * paymoney 交易金额
     * serial_number 冠字号
     * bitmap64code base64 字符串
     */
    public static void printThfwmOrElectronicCash(PosFuncs posFuncs,
                                                  String time,
                                                  String make_type,
                                                  String runningwaterNo,
                                                  String noName,
                                                  String cardNo,
                                                  String paymoney,
                                                  String bitmap64code,
                                                  onPrintinterface mOnPrintinterface) {
        new Thread() {
            @Override
            public void run() {
                try {
                    posFuncs.printerClearBuffer();
                    posFuncs.printerAppendLargeTextAlignCenter("惠农金服便利店");
                    posFuncs.printerAppendLargeTextAlignCenter("助农取款服务点通用凭证");
                    posFuncs.printerAppendTextline("交易时间 :" + time);
                    posFuncs.printerAppendTextline("设备号 :" + SPStaticUtils.getString("DeviceNum"));
                    posFuncs.printerAppendTextline("凭证序号 :" + SPStaticUtils.getInt("ccsno", 1));
                    posFuncs.printerAppendTextline("流水号 :" + runningwaterNo);
                    posFuncs.printerAppendTextline("客户经理 :" + SPStaticUtils.getString("ManagerNum"));
                    posFuncs.printerAppendTextline("交易名称 :" + make_type);
                    posFuncs.printerAppendTextline("账户名称 :" + noName);
                    posFuncs.printerAppendTextline("卡号 :" + cardNo);
                    posFuncs.printerAppendTextline("交易金额 :" + paymoney);
                    Bitmap bitmap = null;
                    try {
                        byte[] bitmapByte = Base64.decode(bitmap64code, Base64.DEFAULT);
                        bitmap = BitmapFactory.decodeByteArray(bitmapByte, 0, bitmapByte.length);
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                    posFuncs.printerAppendBitmap(scaleBitmap(bitmap));
                    posFuncs.printerAppendTextline("本人已确认银行打印记录正确无误");
                    posFuncs.printerAppendTextline("");
                    posFuncs.printerAppendTextline("客户签字确认 :");
                    posFuncs.printerAppendTextline("");
                    posFuncs.printerAppendTextline("                  ---银行留存---");
                    posFuncs.printerAppendTextline("");
                    posFuncs.printerAppendTextline("经办人员 :");
                    posFuncs.printerAppendTextline("");
                    posFuncs.printerAppendTextline("");
                    posFuncs.printerAppendTextline("");
                    posFuncs.printerAppendTextline("");
                    posFuncs.printerAppendTextline("");

                    posFuncs.startPrint(new PosCallbacks.PrintCallbacaks() {
                        @Override
                        public void onSuccess() {
                            mOnPrintinterface.success("打印成功");
                        }

                        @Override
                        public void onFailed(String error) {
                            KLog.e(error);
                            if (error.equals("Lack Paper")) {
                                error = "打印机缺纸";
                            }
                            mOnPrintinterface.failed(error);
                        }
                    });
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }.start();
    }

    public static void printThfwmOrElectronicCash2(PosFuncs posFuncs,
                                                   String time,
                                                   String make_type,
                                                   String runningwaterNo,
                                                   String noName,
                                                   String cardNo,
                                                   String paymoney,
                                                   String bitmap64code,
                                                   onPrintinterface mOnPrintinterface) {
        new Thread() {
            @Override
            public void run() {
                try {
                    posFuncs.printerClearBuffer();
                    posFuncs.printerAppendLargeTextAlignCenter("惠农金服便利店");
                    posFuncs.printerAppendLargeTextAlignCenter("助农取款服务点通用凭证");
                    posFuncs.printerAppendTextline("交易时间 :" + time);
                    posFuncs.printerAppendTextline("设备号 :" + SPStaticUtils.getString("DeviceNum"));
                    posFuncs.printerAppendTextline("凭证序号 :" + SPStaticUtils.getInt("ccsno", 1));
                    posFuncs.printerAppendTextline("流水号 :" + runningwaterNo);
                    posFuncs.printerAppendTextline("客户经理 :" + SPStaticUtils.getString("ManagerNum"));
                    posFuncs.printerAppendTextline("交易名称 :" + make_type);
                    if (make_type.equals("他行助农取款")) {
                        posFuncs.printerAppendTextline("账户名称 :" + noName);
                    } else {
                        posFuncs.printerAppendTextline("账户名称 :" + "*" + noName.substring(1));
                    }
                    posFuncs.printerAppendTextline("卡号 :" + cardNo.substring(0, cardNo.length() - 5) + "****" + cardNo.substring(cardNo.length() - 1));
                    posFuncs.printerAppendTextline("交易金额 :" + paymoney);
                    Bitmap bitmap = null;
                    try {
                        byte[] bitmapByte = Base64.decode(bitmap64code, Base64.DEFAULT);
                        bitmap = BitmapFactory.decodeByteArray(bitmapByte, 0, bitmapByte.length);
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                    posFuncs.printerAppendBitmap(scaleBitmap(bitmap));
                    posFuncs.printerAppendTextline("本人已确认银行打印记录正确无误");
                    posFuncs.printerAppendTextline("");
                    posFuncs.printerAppendTextline("客户签字确认 :");
                    posFuncs.printerAppendTextline("");
                    posFuncs.printerAppendTextline("                  ---客户留存---");
                    posFuncs.printerAppendTextline("");
                    posFuncs.printerAppendTextline("经办人员 :");
                    posFuncs.printerAppendTextline("");
                    posFuncs.printerAppendTextline("");
                    posFuncs.printerAppendTextline("");
                    posFuncs.printerAppendTextline("");
                    posFuncs.printerAppendTextline("");

                    posFuncs.startPrint(new PosCallbacks.PrintCallbacaks() {
                        @Override
                        public void onSuccess() {
                            mOnPrintinterface.success("打印成功");
                        }

                        @Override
                        public void onFailed(String error) {
                            if (error.equals("Lack Paper")) {
                                error = "打印机缺纸";
                            }
                            mOnPrintinterface.failed(error);
                        }
                    });
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }.start();
    }
    //    <!-- 以上是助农取款 -->
    //    <!-- 以上是助农取款 -->
    //    <!-- 以上是助农取款 -->
    //    <!-- 以上是助农取款 -->
    //    <!-- 以上是助农取款 -->
    //    <!-- 以上是助农取款 -->
    //    <!-- 以上是助农取款 -->

    /**
     * 修改密码
     * <p>
     * 打印回执单
     * time 时间
     * ccsno 凭证序号
     * termno 终端号
     * manager 经理号
     * make_type 交易名称
     * runningwaterNo 流水号
     * noName 账户名称
     * cardNo 卡号
     */
    public static void printChangePsword(PosFuncs posFuncs,
                                         String time,
                                         String make_type,
                                         String runningwaterNo,
                                         String noName,
                                         String cardNo,
                                         String bitmap64code,
                                         onPrintinterface mOnPrintinterface) {
        new Thread() {
            @Override
            public void run() {
                try {
                    posFuncs.printerClearBuffer();
                    posFuncs.printerAppendLargeTextAlignCenter("惠农金服便利店");
                    posFuncs.printerAppendLargeTextAlignCenter("助农取款服务点通用凭证");
                    posFuncs.printerAppendTextline("交易时间 :" + time);
                    posFuncs.printerAppendTextline("设备号 :" + SPStaticUtils.getString("DeviceNum"));
                    posFuncs.printerAppendTextline("凭证序号 :" + SPStaticUtils.getInt("ccsno", 1));
                    posFuncs.printerAppendTextline("流水号 :" + runningwaterNo);
                    posFuncs.printerAppendTextline("客户经理 :" + SPStaticUtils.getString("ManagerNum"));
                    posFuncs.printerAppendTextline("交易名称 :" + make_type);
                    posFuncs.printerAppendTextline("账户名称 :" + noName);
                    posFuncs.printerAppendTextline("卡号 :" + cardNo);
                    Bitmap bitmap = null;
                    try {
                        byte[] bitmapByte = Base64.decode(bitmap64code, Base64.DEFAULT);
                        bitmap = BitmapFactory.decodeByteArray(bitmapByte, 0, bitmapByte.length);
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                    posFuncs.printerAppendBitmap(scaleBitmap(bitmap));
                    posFuncs.printerAppendTextline("本人已确认银行打印记录正确无误");
                    posFuncs.printerAppendTextline("");
                    posFuncs.printerAppendTextline("客户签字确认 :");
                    posFuncs.printerAppendTextline("");
                    posFuncs.printerAppendTextline("                  ---银行留存---");
                    posFuncs.printerAppendTextline("");
                    posFuncs.printerAppendTextline("经办人员 :");
                    posFuncs.printerAppendTextline("");
                    posFuncs.printerAppendTextline("");
                    posFuncs.printerAppendTextline("");
                    posFuncs.printerAppendTextline("");
                    posFuncs.printerAppendTextline("");
                    posFuncs.startPrint(new PosCallbacks.PrintCallbacaks() {
                        @Override
                        public void onSuccess() {
                            mOnPrintinterface.success("打印成功");
                        }

                        @Override
                        public void onFailed(String error) {
                            if (error.equals("Lack Paper")) {
                                error = "打印机缺纸";
                            }
                            mOnPrintinterface.failed(error);
                        }
                    });
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }.start();

    }

    public static void printChangePsword2(PosFuncs posFuncs,

                                          String time,
                                          String make_type,
                                          String runningwaterNo,
                                          String noName,
                                          String cardNo,
                                          String bitmap64code,
                                          onPrintinterface mOnPrintinterface) {
        new Thread() {
            @Override
            public void run() {
                try {
                    posFuncs.printerClearBuffer();
                    posFuncs.printerAppendLargeTextAlignCenter("惠农金服便利店");
                    posFuncs.printerAppendLargeTextAlignCenter("助农取款服务点通用凭证");
                    posFuncs.printerAppendTextline("交易时间 :" + time);
                    posFuncs.printerAppendTextline("设备号 :" + SPStaticUtils.getString("DeviceNum"));
                    posFuncs.printerAppendTextline("凭证序号 :" + SPStaticUtils.getInt("ccsno", 1));
                    posFuncs.printerAppendTextline("流水号 :" + runningwaterNo);
                    posFuncs.printerAppendTextline("客户经理 :" + SPStaticUtils.getString("ManagerNum"));
                    posFuncs.printerAppendTextline("交易名称 :" + make_type);
                    posFuncs.printerAppendTextline("账户名称 :" + "*" + noName.substring(1));
                    posFuncs.printerAppendTextline("卡号 :" + cardNo.substring(0, cardNo.length() - 5) + "****" + cardNo.substring(cardNo.length() - 1));

                    Bitmap bitmap = null;
                    try {
                        byte[] bitmapByte = Base64.decode(bitmap64code, Base64.DEFAULT);
                        bitmap = BitmapFactory.decodeByteArray(bitmapByte, 0, bitmapByte.length);
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                    posFuncs.printerAppendBitmap(scaleBitmap(bitmap));
                    posFuncs.printerAppendTextline("本人已确认银行打印记录正确无误");
                    posFuncs.printerAppendTextline("");
                    posFuncs.printerAppendTextline("客户签字确认 :");
                    posFuncs.printerAppendTextline("");
                    posFuncs.printerAppendTextline("                  ---客户留存---");
                    posFuncs.printerAppendTextline("");
                    posFuncs.printerAppendTextline("经办人员 :");
                    posFuncs.printerAppendTextline("");
                    posFuncs.printerAppendTextline("");
                    posFuncs.printerAppendTextline("");
                    posFuncs.printerAppendTextline("");
                    posFuncs.printerAppendTextline("");
                    posFuncs.startPrint(new PosCallbacks.PrintCallbacaks() {
                        @Override
                        public void onSuccess() {
                            mOnPrintinterface.success("打印成功");
                        }

                        @Override
                        public void onFailed(String error) {
                            if (error.equals("Lack Paper")) {
                                error = "打印机缺纸";
                            }
                            mOnPrintinterface.failed(error);
                        }
                    });
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }.start();

    }
    //    <!-- 以上修改密码 -->
    //    <!-- 以上修改密码 -->
    //    <!-- 以上修改密码 -->
    //    <!-- 以上修改密码 -->
    //    <!-- 以上修改密码 -->
    //    <!-- 以上修改密码 -->
    //    <!-- 以上修改密码 -->

    /**
     * 定活自转签约 、 周周赢签约
     * <p>
     * lsaveMoney 活期预留金额
     * upMoney 功能起点金额
     * functionPotins 功能基数
     */
    public static void dhSelfSingOrWeekSing(PosFuncs posFuncs,
                                            String time,
                                            String make_type,
                                            String runningwaterNo,
                                            String noName,
                                            String cardNo,
                                            String lsaveMoney,
                                            String upMoney,
                                            String functionPotins,
                                            String bitmap64code,
                                            onPrintinterface mOnPrintinterface) {
        new Thread() {
            @Override
            public void run() {
                try {
                    posFuncs.printerClearBuffer();
                    posFuncs.printerAppendLargeTextAlignCenter("惠农金服便利店");
                    posFuncs.printerAppendLargeTextAlignCenter("助农取款服务点通用凭证");
                    posFuncs.printerAppendTextline("交易时间 :" + time);
                    posFuncs.printerAppendTextline("设备号 :" + SPStaticUtils.getString("DeviceNum"));
                    posFuncs.printerAppendTextline("凭证序号 :" + SPStaticUtils.getInt("ccsno", 1));
                    posFuncs.printerAppendTextline("流水号 :" + runningwaterNo);
                    posFuncs.printerAppendTextline("客户经理 :" + SPStaticUtils.getString("ManagerNum"));
                    posFuncs.printerAppendTextline("交易名称 :" + make_type);
                    posFuncs.printerAppendTextline("账户名称 :" + noName);
                    posFuncs.printerAppendTextline("卡号 :" + cardNo);
                    posFuncs.printerAppendTextline("活期预留金额 :" + lsaveMoney);
                    posFuncs.printerAppendTextline("功能起点金额 :" + upMoney);
                    posFuncs.printerAppendTextline("功能基数 :" + functionPotins);
                    Bitmap bitmap = null;
                    try {
                        byte[] bitmapByte = Base64.decode(bitmap64code, Base64.DEFAULT);
                        bitmap = BitmapFactory.decodeByteArray(bitmapByte, 0, bitmapByte.length);
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                    posFuncs.printerAppendBitmap(scaleBitmap(bitmap));
                    posFuncs.printerAppendTextline("本人已确认银行打印记录正确无误");
                    posFuncs.printerAppendTextline("");
                    posFuncs.printerAppendTextline("客户签字确认 :");
                    posFuncs.printerAppendTextline("");
                    posFuncs.printerAppendTextline("                  ---银行留存---");
                    posFuncs.printerAppendTextline("");
                    posFuncs.printerAppendTextline("经办人员 :");
                    posFuncs.printerAppendTextline("");
                    posFuncs.printerAppendTextline("");
                    posFuncs.printerAppendTextline("");
                    posFuncs.printerAppendTextline("");
                    posFuncs.printerAppendTextline("");
                    posFuncs.startPrint(new PosCallbacks.PrintCallbacaks() {
                        @Override
                        public void onSuccess() {
                            mOnPrintinterface.success("打印成功");
                        }

                        @Override
                        public void onFailed(String error) {
                            if (error.equals("Lack Paper")) {
                                error = "打印机缺纸";
                            }
                            mOnPrintinterface.failed(error);
                        }
                    });
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }.start();

    }

    public static void dhSelfSingOrWeekSing2(PosFuncs posFuncs,
                                             String time,
                                             String make_type,
                                             String runningwaterNo,
                                             String noName,
                                             String cardNo,
                                             String lsaveMoney,
                                             String upMoney,
                                             String functionPotins,
                                             String bitmap64code,
                                             onPrintinterface mOnPrintinterface) {
        new Thread() {
            @Override
            public void run() {
                try {
                    posFuncs.printerClearBuffer();
                    posFuncs.printerAppendLargeTextAlignCenter("惠农金服便利店");
                    posFuncs.printerAppendLargeTextAlignCenter("助农取款服务点通用凭证");
                    posFuncs.printerAppendTextline("交易时间 :" + time);
                    posFuncs.printerAppendTextline("设备号 :" + SPStaticUtils.getString("DeviceNum"));
                    posFuncs.printerAppendTextline("凭证序号 :" + SPStaticUtils.getInt("ccsno", 1));
                    posFuncs.printerAppendTextline("流水号 :" + runningwaterNo);
                    posFuncs.printerAppendTextline("客户经理 :" + SPStaticUtils.getString("ManagerNum"));
                    posFuncs.printerAppendTextline("交易名称 :" + make_type);
                    posFuncs.printerAppendTextline("账户名称 :" + "*" + noName.substring(1));
                    posFuncs.printerAppendTextline("卡号 :" + cardNo.substring(0, cardNo.length() - 5) + "****" + cardNo.substring(cardNo.length() - 1));

                    posFuncs.printerAppendTextline("活期预留金额 :" + lsaveMoney);
                    posFuncs.printerAppendTextline("功能起点金额 :" + upMoney);
                    posFuncs.printerAppendTextline("功能基数 :" + functionPotins);
                    Bitmap bitmap = null;
                    try {
                        byte[] bitmapByte = Base64.decode(bitmap64code, Base64.DEFAULT);
                        bitmap = BitmapFactory.decodeByteArray(bitmapByte, 0, bitmapByte.length);
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                    posFuncs.printerAppendBitmap(scaleBitmap(bitmap));
                    posFuncs.printerAppendTextline("本人已确认银行打印记录正确无误");
                    posFuncs.printerAppendTextline("");
                    posFuncs.printerAppendTextline("客户签字确认 :");
                    posFuncs.printerAppendTextline("");
                    posFuncs.printerAppendTextline("                  ---客户留存---");
                    posFuncs.printerAppendTextline("");
                    posFuncs.printerAppendTextline("经办人员 :");
                    posFuncs.printerAppendTextline("");
                    posFuncs.printerAppendTextline("");
                    posFuncs.printerAppendTextline("");
                    posFuncs.printerAppendTextline("");
                    posFuncs.printerAppendTextline("");
                    posFuncs.startPrint(new PosCallbacks.PrintCallbacaks() {
                        @Override
                        public void onSuccess() {
                            mOnPrintinterface.success("打印成功");
                        }

                        @Override
                        public void onFailed(String error) {
                            if (error.equals("Lack Paper")) {
                                error = "打印机缺纸";
                            }
                            mOnPrintinterface.failed(error);
                        }
                    });
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }.start();

    }
    //    <!-- 定活自转签约 、 周周赢签约 -->
    //    <!-- 定活自转签约 、 周周赢签约 -->
    //    <!-- 定活自转签约 、 周周赢签约 -->
    //    <!-- 定活自转签约 、 周周赢签约 -->
    //    <!-- 定活自转签约 、 周周赢签约 -->
    //    <!-- 定活自转签约 、 周周赢签约 -->
    //    <!-- 定活自转签约 、 周周赢签约 -->

    /**
     * 定活自转解约 、 周周赢解约
     * <p>
     * interest 利息
     * lsaveMoney 活期预存金额
     * upMoney 功能起点金额
     * functionPotins 功能基数
     */

    public static void dhSelfOpenOrWeekOpen(PosFuncs posFuncs,
                                            String time,
                                            String make_type,
                                            String runningwaterNo,
                                            String noName,
                                            String cardNo,
                                            String interest,
                                            String lsaveMoney,
                                            String upMoney,
                                            String functionPotins,
                                            String bitmap64code,
                                            onPrintinterface mOnPrintinterface) {
        new Thread() {
            @Override
            public void run() {
                try {
                    posFuncs.printerClearBuffer();
                    posFuncs.printerAppendLargeTextAlignCenter("惠农金服便利店");
                    posFuncs.printerAppendLargeTextAlignCenter("助农取款服务点通用凭证");
                    posFuncs.printerAppendTextline("交易时间 :" + time);
                    posFuncs.printerAppendTextline("设备号 :" + SPStaticUtils.getString("DeviceNum"));
                    posFuncs.printerAppendTextline("凭证序号 :" + SPStaticUtils.getInt("ccsno", 1));
                    posFuncs.printerAppendTextline("流水号 :" + runningwaterNo);
                    posFuncs.printerAppendTextline("客户经理 :" + SPStaticUtils.getString("ManagerNum"));
                    posFuncs.printerAppendTextline("交易名称 :" + make_type);
                    posFuncs.printerAppendTextline("账户名称 :" + noName);
                    posFuncs.printerAppendTextline("卡号 :" + cardNo);
                    posFuncs.printerAppendTextline("利息 :" + interest);
                    posFuncs.printerAppendTextline("活期预留金额 :" + lsaveMoney);
                    posFuncs.printerAppendTextline("功能起点金额 :" + upMoney);
                    posFuncs.printerAppendTextline("功能基数 :" + functionPotins);
                    Bitmap bitmap = null;
                    try {
                        byte[] bitmapByte = Base64.decode(bitmap64code, Base64.DEFAULT);
                        bitmap = BitmapFactory.decodeByteArray(bitmapByte, 0, bitmapByte.length);
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                    posFuncs.printerAppendBitmap(scaleBitmap(bitmap));
                    posFuncs.printerAppendTextline("本人已确认银行打印记录正确无误");
                    posFuncs.printerAppendTextline("");
                    posFuncs.printerAppendTextline("客户签字确认 :");
                    posFuncs.printerAppendTextline("");
                    posFuncs.printerAppendTextline("                  ---银行留存---");
                    posFuncs.printerAppendTextline("");
                    posFuncs.printerAppendTextline("经办人员 :");
                    posFuncs.printerAppendTextline("");
                    posFuncs.printerAppendTextline("");
                    posFuncs.printerAppendTextline("");
                    posFuncs.printerAppendTextline("");
                    posFuncs.printerAppendTextline("");
                    posFuncs.startPrint(new PosCallbacks.PrintCallbacaks() {
                        @Override
                        public void onSuccess() {
                            mOnPrintinterface.success("打印成功");
                        }

                        @Override
                        public void onFailed(String error) {
                            if (error.equals("Lack Paper")) {
                                error = "打印机缺纸";
                            }
                            mOnPrintinterface.failed(error);
                        }
                    });
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }.start();
    }

    public static void dhSelfOpenOrWeekOpen2(PosFuncs posFuncs,
                                             String time,
                                             String make_type,
                                             String runningwaterNo,
                                             String noName,
                                             String cardNo,
                                             String interest,
                                             String lsaveMoney,
                                             String upMoney,
                                             String functionPotins,
                                             String bitmap64code,
                                             onPrintinterface mOnPrintinterface) {
        new Thread() {
            @Override
            public void run() {
                try {
                    posFuncs.printerClearBuffer();
                    posFuncs.printerAppendLargeTextAlignCenter("惠农金服便利店");
                    posFuncs.printerAppendLargeTextAlignCenter("助农取款服务点通用凭证");
                    posFuncs.printerAppendTextline("交易时间 :" + time);
                    posFuncs.printerAppendTextline("设备号 :" + SPStaticUtils.getString("DeviceNum"));
                    posFuncs.printerAppendTextline("凭证序号 :" + SPStaticUtils.getInt("ccsno", 1));
                    posFuncs.printerAppendTextline("流水号 :" + runningwaterNo);
                    posFuncs.printerAppendTextline("客户经理 :" + SPStaticUtils.getString("ManagerNum"));
                    posFuncs.printerAppendTextline("交易名称 :" + make_type);
                    posFuncs.printerAppendTextline("账户名称 :" + "*" + noName.substring(1));
                    posFuncs.printerAppendTextline("卡号 :" + cardNo.substring(0, cardNo.length() - 5) + "****" + cardNo.substring(cardNo.length() - 1));

                    posFuncs.printerAppendTextline("利息 :" + interest);
                    posFuncs.printerAppendTextline("活期预留金额 :" + lsaveMoney);
                    posFuncs.printerAppendTextline("功能起点金额 :" + upMoney);
                    posFuncs.printerAppendTextline("功能基数 :" + functionPotins);
                    Bitmap bitmap = null;
                    try {
                        byte[] bitmapByte = Base64.decode(bitmap64code, Base64.DEFAULT);
                        bitmap = BitmapFactory.decodeByteArray(bitmapByte, 0, bitmapByte.length);
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                    posFuncs.printerAppendBitmap(scaleBitmap(bitmap));
                    posFuncs.printerAppendTextline("本人已确认银行打印记录正确无误");
                    posFuncs.printerAppendTextline("");
                    posFuncs.printerAppendTextline("客户签字确认 :");
                    posFuncs.printerAppendTextline("");
                    posFuncs.printerAppendTextline("                  ---客户留存---");
                    posFuncs.printerAppendTextline("");
                    posFuncs.printerAppendTextline("经办人员 :");
                    posFuncs.printerAppendTextline("");
                    posFuncs.printerAppendTextline("");
                    posFuncs.printerAppendTextline("");
                    posFuncs.printerAppendTextline("");
                    posFuncs.printerAppendTextline("");

                    posFuncs.startPrint(new PosCallbacks.PrintCallbacaks() {
                        @Override
                        public void onSuccess() {
                            mOnPrintinterface.success("打印成功");
                        }

                        @Override
                        public void onFailed(String error) {
                            if (error.equals("Lack Paper")) {
                                error = "打印机缺纸";
                            }
                            mOnPrintinterface.failed(error);
                        }
                    });
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }.start();
    }
    //    <!-- 以上是定活自转签约 、 周周赢解约 -->
    //    <!-- 以上是定活自转签约 、 周周赢解约 -->
    //    <!-- 以上是定活自转签约 、 周周赢解约 -->
    //    <!-- 以上是定活自转签约 、 周周赢解约 -->
    //    <!-- 以上是定活自转签约 、 周周赢解约 -->
    //    <!-- 以上是定活自转签约 、 周周赢解约 -->

    /**
     * 定转活
     * <p>
     * productName 产品名称
     * rateofinterest 利率
     * zctag 转存标志
     * datedue 到期日期
     * openData 开户日期
     * drawmoney 支取金额
     * balance 账户余额
     * drawtype 支取类型
     * interest 利息
     */
    public static void printCurrentDeposit(PosFuncs posFuncs,
                                           String time,
                                           String make_type,
                                           String runningwaterNo,
                                           String penno,
                                           String noName,
                                           String cardNo,
                                           String productName,
                                           String rateofinterest,
                                           String zctag,
                                           String datedue,
                                           String openData,
                                           String drawmoney,
                                           String balance,
                                           String interest,
                                           String bitmap64code,
                                           onPrintinterface mOnPrintinterface) {
        new Thread() {
            @Override
            public void run() {
                try {
                    posFuncs.printerClearBuffer();
                    posFuncs.printerAppendLargeTextAlignCenter("惠农金服便利店");
                    posFuncs.printerAppendLargeTextAlignCenter("助农取款服务点通用凭证");
                    posFuncs.printerAppendTextline("交易时间 :" + time);
                    posFuncs.printerAppendTextline("设备号 :" + SPStaticUtils.getString("DeviceNum"));
                    posFuncs.printerAppendTextline("凭证序号 :" + SPStaticUtils.getInt("ccsno", 1));
                    posFuncs.printerAppendTextline("流水号 :" + runningwaterNo);
                    posFuncs.printerAppendTextline("客户经理 :" + SPStaticUtils.getString("ManagerNum"));
                    posFuncs.printerAppendTextline("交易名称 :" + make_type);
                    posFuncs.printerAppendTextline("账户名称 :" + noName);
                    posFuncs.printerAppendTextline("卡号 :" + cardNo);
                    posFuncs.printerAppendTextline("笔号 :" + penno);
                    posFuncs.printerAppendTextline("产品名称 :" + productName.trim());
                    posFuncs.printerAppendTextline("利率(%) :" + rateofinterest);
                    if (zctag.equals(0)) {
                        posFuncs.printerAppendTextline("转存标志 :" + "不自动转存");//转存标志
                    } else if (zctag.equals(1)) {
                        posFuncs.printerAppendTextline("转存标志 :" + "自动转存");//转存标志
                    } else if (zctag.equals(2)) {
                        posFuncs.printerAppendTextline("转存标志 :" + "本息转存");//转存标志
                    }
                    posFuncs.printerAppendTextline("到期日期 :" + datedue);
                    posFuncs.printerAppendTextline("开户日期 :" + openData);

                    if (balance.equals("0.00")) {
                        posFuncs.printerAppendTextline("支取金额 :" + drawmoney);
                        posFuncs.printerAppendTextline("支取类型 :" + "全部支取");
                        posFuncs.printerAppendTextline("账户余额 : 0.00");


                    } else {
                        posFuncs.printerAppendTextline("支取金额 :" + drawmoney);
                        posFuncs.printerAppendTextline("支取类型 :" + "部分支取");
                        posFuncs.printerAppendTextline("账户余额 :" + balance);


                    }

                    posFuncs.printerAppendTextline("利息 : ￥" + interest);
                    Bitmap bitmap = null;
                    try {
                        byte[] bitmapByte = Base64.decode(bitmap64code, Base64.DEFAULT);
                        bitmap = BitmapFactory.decodeByteArray(bitmapByte, 0, bitmapByte.length);
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                    posFuncs.printerAppendBitmap(scaleBitmap(bitmap));
                    posFuncs.printerAppendTextline("本人已确认银行打印记录正确无误");
                    posFuncs.printerAppendTextline("");
                    posFuncs.printerAppendTextline("客户签字确认 :");
                    posFuncs.printerAppendTextline("");
                    posFuncs.printerAppendTextline("                  ---银行留存---");
                    posFuncs.printerAppendTextline("");
                    posFuncs.printerAppendTextline("经办人员 :");
                    posFuncs.printerAppendTextline("");
                    posFuncs.printerAppendTextline("");
                    posFuncs.printerAppendTextline("");
                    posFuncs.printerAppendTextline("");
                    posFuncs.printerAppendTextline("");

                    posFuncs.startPrint(new PosCallbacks.PrintCallbacaks() {
                        @Override
                        public void onSuccess() {
                            mOnPrintinterface.success("打印成功");
                        }

                        @Override
                        public void onFailed(String error) {
                            if (error.equals("Lack Paper")) {
                                error = "打印机缺纸";
                            }
                            mOnPrintinterface.failed(error);
                        }
                    });
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }.start();

    }

    public static void printCurrentDeposit2(PosFuncs posFuncs,
                                            String time,
                                            String make_type,
                                            String runningwaterNo,
                                            String penno,
                                            String noName,
                                            String cardNo,
                                            String productName,
                                            String rateofinterest,
                                            String zctag,
                                            String datedue,
                                            String openData,
                                            String drawmoney,
                                            String balance,
                                            String interest,
                                            String bitmap64code,
                                            onPrintinterface mOnPrintinterface) {

        new Thread() {
            @Override
            public void run() {
                try {
                    posFuncs.printerClearBuffer();
                    posFuncs.printerAppendLargeTextAlignCenter("惠农金服便利店");
                    posFuncs.printerAppendLargeTextAlignCenter("助农取款服务点通用凭证");
                    posFuncs.printerAppendTextline("交易时间 :" + time);
                    posFuncs.printerAppendTextline("设备号 :" + SPStaticUtils.getString("DeviceNum"));
                    posFuncs.printerAppendTextline("凭证序号 :" + SPStaticUtils.getInt("ccsno", 1));
                    posFuncs.printerAppendTextline("流水号 :" + runningwaterNo);
                    posFuncs.printerAppendTextline("客户经理 :" + SPStaticUtils.getString("ManagerNum"));
                    posFuncs.printerAppendTextline("交易名称 :" + make_type);
                    posFuncs.printerAppendTextline("账户名称 :" + "*" + noName.substring(1));
                    posFuncs.printerAppendTextline("卡号 :" + cardNo.substring(0, cardNo.length() - 5) + "****" + cardNo.substring(cardNo.length() - 1));
                    posFuncs.printerAppendTextline("笔号 :" + penno);
                    posFuncs.printerAppendTextline("产品名称 :" + productName.trim());
                    posFuncs.printerAppendTextline("利率(%) :" + rateofinterest);
                    if (zctag.equals(0)) {
                        posFuncs.printerAppendTextline("转存标志 :" + "不自动转存");//转存标志
                    } else if (zctag.equals(1)) {
                        posFuncs.printerAppendTextline("转存标志 :" + "自动转存");//转存标志
                    } else if (zctag.equals(2)) {
                        posFuncs.printerAppendTextline("转存标志 :" + "本息转存");//转存标志
                    }
                    posFuncs.printerAppendTextline("到期日期 :" + datedue);
                    posFuncs.printerAppendTextline("开户日期 :" + openData);

                    if (balance.equals("0.00")) {
                        posFuncs.printerAppendTextline("支取金额 :" + drawmoney);
                        posFuncs.printerAppendTextline("支取类型 :" + "全部支取");
                        posFuncs.printerAppendTextline("账户余额 : 0.00");


                    } else {
                        posFuncs.printerAppendTextline("支取金额 :" + drawmoney);
                        posFuncs.printerAppendTextline("支取类型 :" + "部分支取");
                        posFuncs.printerAppendTextline("账户余额 :" + balance);


                    }

                    posFuncs.printerAppendTextline("利息 : ￥" + interest);
                    Bitmap bitmap = null;
                    try {
                        byte[] bitmapByte = Base64.decode(bitmap64code, Base64.DEFAULT);
                        bitmap = BitmapFactory.decodeByteArray(bitmapByte, 0, bitmapByte.length);
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                    posFuncs.printerAppendBitmap(scaleBitmap(bitmap));
                    posFuncs.printerAppendTextline("本人已确认银行打印记录正确无误");
                    posFuncs.printerAppendTextline("");
                    posFuncs.printerAppendTextline("客户签字确认 :");
                    posFuncs.printerAppendTextline("");
                    posFuncs.printerAppendTextline("                  ---客户留存---");
                    posFuncs.printerAppendTextline("");
                    posFuncs.printerAppendTextline("经办人员 :");
                    posFuncs.printerAppendTextline("");
                    posFuncs.printerAppendTextline("");
                    posFuncs.printerAppendTextline("");
                    posFuncs.printerAppendTextline("");
                    posFuncs.printerAppendTextline("");

                    posFuncs.startPrint(new PosCallbacks.PrintCallbacaks() {
                        @Override
                        public void onSuccess() {
                            mOnPrintinterface.success("打印成功");
                        }

                        @Override
                        public void onFailed(String error)
                        {
                            if (error.equals("Lack Paper")) {
                                error = "打印机缺纸";
                            }
                            mOnPrintinterface.failed(error);
                        }
                    });
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }.start();

    }
    //    <!-- 以上是定转活 -->
    //    <!-- 以上是定转活 -->
    //    <!-- 以上是定转活 -->
    //    <!-- 以上是定转活 -->
    //    <!-- 以上是定转活 -->
    //    <!-- 以上是定转活 -->
    //    <!-- 以上是定转活 -->

    /**
     * 活转定
     * <p>
     * penno 笔数
     * noName 账户名称
     * cardNo 卡号
     * productName 产品名称
     * saveData 存期
     * datedue 到期日期
     * rateofinterest 利率
     * saveMoney 存入金额
     * zctag 转存标志
     * payinterest 付息周期
     * interest 预计利息
     */
    public static void CurrentTrapezium(PosFuncs posFuncs,
                                        String time,
                                        String make_type,
                                        String runningwaterNo,
                                        String penno,
                                        String noName,
                                        String cardNo,
                                        String productName,
                                        String saveData,
                                        String datedue,
                                        String rateofinterest,
                                        String saveMoney,
                                        String zctag,
                                        String interest,
                                        String bitmap64code,
                                        onPrintinterface mOnPrintinterface) {
        new Thread() {
            @Override
            public void run() {
                try {
                    posFuncs.printerClearBuffer();
                    posFuncs.printerAppendLargeTextAlignCenter("惠农金服便利店");
                    posFuncs.printerAppendLargeTextAlignCenter("助农取款服务点通用凭证");
                    posFuncs.printerAppendTextline("交易时间 :" + time);
                    posFuncs.printerAppendTextline("设备号 :" + SPStaticUtils.getString("DeviceNum"));
                    posFuncs.printerAppendTextline("凭证序号 :" + SPStaticUtils.getInt("ccsno", 1));
                    posFuncs.printerAppendTextline("流水号 :" + runningwaterNo);
                    posFuncs.printerAppendTextline("客户经理 :" + SPStaticUtils.getString("ManagerNum"));

                    posFuncs.printerAppendTextline("交易名称 :" + make_type);
                    posFuncs.printerAppendTextline("账户名称 :" + noName);
                    posFuncs.printerAppendTextline("卡号 :" + cardNo);
                    posFuncs.printerAppendTextline("笔号 :" + penno);
                    posFuncs.printerAppendTextline("产品名称 :" + productName);
                    posFuncs.printerAppendTextline("存期 :" + saveData);
                    posFuncs.printerAppendTextline("到期日期 :" + datedue);
                    posFuncs.printerAppendTextline("利率(%) :" + rateofinterest);


                    posFuncs.printerAppendTextline("存入金额 :" + GetMoneyLvUtils.getInputMoney(saveMoney));
                    posFuncs.printerAppendTextline("转存标志 :" + zctag);
                    posFuncs.printerAppendTextline("预计利息 :" + interest);
                    Bitmap bitmap = null;
                    try {
                        byte[] bitmapByte = Base64.decode(bitmap64code, Base64.DEFAULT);
                        bitmap = BitmapFactory.decodeByteArray(bitmapByte, 0, bitmapByte.length);
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                    posFuncs.printerAppendBitmap(scaleBitmap(bitmap));
                    posFuncs.printerAppendTextline("本人已确认银行打印记录正确无误");
                    posFuncs.printerAppendTextline("");
                    posFuncs.printerAppendTextline("客户签字确认 :");
                    posFuncs.printerAppendTextline("");
                    posFuncs.printerAppendTextline("                  ---银行留存---");
                    posFuncs.printerAppendTextline("");
                    posFuncs.printerAppendTextline("经办人员 :");
                    posFuncs.printerAppendTextline("");
                    posFuncs.printerAppendTextline("");
                    posFuncs.printerAppendTextline("");
                    posFuncs.printerAppendTextline("");
                    posFuncs.printerAppendTextline("");

                    posFuncs.startPrint(new PosCallbacks.PrintCallbacaks() {
                        @Override
                        public void onSuccess() {
                            mOnPrintinterface.success("打印成功");
                        }

                        @Override
                        public void onFailed(String error) {
                            if (error.equals("Lack Paper")) {
                                error = "打印机缺纸";
                            }

                            mOnPrintinterface.failed(error);
                        }
                    });
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }.start();

    }

    public static void CurrentTrapezium2(PosFuncs posFuncs,
                                         String time,
                                         String make_type,
                                         String runningwaterNo,
                                         String penno,
                                         String noName,
                                         String cardNo,
                                         String productName,
                                         String saveData,
                                         String datedue,
                                         String rateofinterest,
                                         String saveMoney,
                                         String zctag,
                                         String interest,
                                         String bitmap64code,
                                         onPrintinterface mOnPrintinterface) {
        new Thread() {
            @Override
            public void run() {
                try {
                    posFuncs.printerClearBuffer();
                    posFuncs.printerAppendLargeTextAlignCenter("惠农金服便利店");
                    posFuncs.printerAppendLargeTextAlignCenter("助农取款服务点通用凭证");
                    posFuncs.printerAppendTextline("交易时间 :" + time);
                    posFuncs.printerAppendTextline("设备号 :" + SPStaticUtils.getString("DeviceNum"));
                    posFuncs.printerAppendTextline("凭证序号 :" + SPStaticUtils.getInt("ccsno", 1));
                    posFuncs.printerAppendTextline("流水号 :" + runningwaterNo);
                    posFuncs.printerAppendTextline("客户经理 :" + SPStaticUtils.getString("ManagerNum"));
                    posFuncs.printerAppendTextline("交易名称 :" + make_type);
                    posFuncs.printerAppendTextline("账户名称 :" + "*" + noName.substring(1));
                    posFuncs.printerAppendTextline("卡号 :" + cardNo.substring(0, cardNo.length() - 5) + "****" + cardNo.substring(cardNo.length() - 1));

                    posFuncs.printerAppendTextline("笔号 :" + penno);
                    posFuncs.printerAppendTextline("产品名称 :" + productName);
                    posFuncs.printerAppendTextline("存期 :" + saveData);
                    posFuncs.printerAppendTextline("到期日期 :" + datedue);
                    posFuncs.printerAppendTextline("利率(%) :" + rateofinterest);

                    String money = "";
                    if (!saveMoney.contains(".")) {
                        money = saveMoney + ".00";
                    } else {
                        String moneys[] = saveMoney.split("\\.");
                        if (moneys[1].length() == 2) {
                            //如果小数点后位长度是2
                            money = saveMoney;
                        } else {
                            money = saveMoney + "0";
                        }
                    }
                    posFuncs.printerAppendTextline("存入金额 :" + GetMoneyLvUtils.getInputMoney(saveMoney));
                    posFuncs.printerAppendTextline("转存标志 :" + zctag);
                    posFuncs.printerAppendTextline("预计利息 :" + interest);
                    Bitmap bitmap = null;
                    try {
                        byte[] bitmapByte = Base64.decode(bitmap64code, Base64.DEFAULT);
                        bitmap = BitmapFactory.decodeByteArray(bitmapByte, 0, bitmapByte.length);
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                    posFuncs.printerAppendBitmap(scaleBitmap(bitmap));
                    posFuncs.printerAppendTextline("本人已确认银行打印记录正确无误");
                    posFuncs.printerAppendTextline("");
                    posFuncs.printerAppendTextline("客户签字确认 :");
                    posFuncs.printerAppendTextline("");
                    posFuncs.printerAppendTextline("                  ---客户留存---");
                    posFuncs.printerAppendTextline("");
                    posFuncs.printerAppendTextline("经办人员 :");
                    posFuncs.printerAppendTextline("");
                    posFuncs.printerAppendTextline("");
                    posFuncs.printerAppendTextline("");
                    posFuncs.printerAppendTextline("");
                    posFuncs.printerAppendTextline("");
                    posFuncs.startPrint(new PosCallbacks.PrintCallbacaks() {
                        @Override
                        public void onSuccess() {
                            mOnPrintinterface.success("打印成功");
                        }

                        @Override
                        public void onFailed(String error) {
                            if (error.equals("Lack Paper")) {
                                error = "打印机缺纸";
                            }
                            mOnPrintinterface.failed(error);
                        }
                    });
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }.start();

    }
    //    <!-- 以上是活转定 -->
    //    <!-- 以上是活转定 -->
    //    <!-- 以上是活转定 -->
    //    <!-- 以上是活转定 -->
    //    <!-- 以上是活转定 -->
    //    <!-- 以上是活转定 -->

    /**
     * 本行转账 、跨行转账
     * <p>
     * singusername 转入户名
     * singNo 转入账（卡）号
     */
    public static void ThebankTransfer(PosFuncs posFuncs,
                                       String time,
                                       String make_type,
                                       String runningwaterNo,
                                       String noName,
                                       String cardNo,
                                       String singusername,
                                       String singNo,
                                       String paymoney,
                                       String bitmap64code,
                                       onPrintinterface mOnPrintinterface) {
        new Thread() {
            @Override
            public void run() {
                try {
                    posFuncs.printerClearBuffer();
                    posFuncs.printerAppendLargeTextAlignCenter("惠农金服便利店");
                    posFuncs.printerAppendLargeTextAlignCenter("助农取款服务点通用凭证");
                    posFuncs.printerAppendTextline("交易时间 :" + time);
                    posFuncs.printerAppendTextline("设备号 :" + SPStaticUtils.getString("DeviceNum"));
                    posFuncs.printerAppendTextline("凭证序号 :" + SPStaticUtils.getInt("ccsno", 1));
                    posFuncs.printerAppendTextline("流水号 :" + runningwaterNo);
                    posFuncs.printerAppendTextline("客户经理 :" + SPStaticUtils.getString("ManagerNum"));
                    posFuncs.printerAppendTextline("交易名称 :" + make_type);
                    posFuncs.printerAppendTextline("账户名称 :" + noName);
                    posFuncs.printerAppendTextline("卡号 :" + cardNo);
                    posFuncs.printerAppendTextline("转入户名 :" + singusername);
                    posFuncs.printerAppendTextline("转入账（卡）号 :");
                    posFuncs.printerAppendTextline(singNo);
                    posFuncs.printerAppendTextline("交易金额 :" + paymoney);
                    Bitmap bitmap = null;
                    try {
                        byte[] bitmapByte = Base64.decode(bitmap64code, Base64.DEFAULT);
                        bitmap = BitmapFactory.decodeByteArray(bitmapByte, 0, bitmapByte.length);
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                    posFuncs.printerAppendBitmap(scaleBitmap(bitmap));
                    posFuncs.printerAppendTextline("本人已确认银行打印记录正确无误");
                    posFuncs.printerAppendTextline("");
                    posFuncs.printerAppendTextline("客户签字确认 :");
                    posFuncs.printerAppendTextline("");
                    posFuncs.printerAppendTextline("                  ---银行留存---");
                    posFuncs.printerAppendTextline("");
                    posFuncs.printerAppendTextline("经办人员 :");
                    posFuncs.printerAppendTextline("");
                    posFuncs.printerAppendTextline("");
                    posFuncs.printerAppendTextline("");
                    posFuncs.printerAppendTextline("");
                    posFuncs.printerAppendTextline("");

                    posFuncs.startPrint(new PosCallbacks.PrintCallbacaks() {
                        @Override
                        public void onSuccess() {
                            mOnPrintinterface.success("打印成功");
                        }

                        @Override
                        public void onFailed(String error)
                        { if (error.equals("Lack Paper")) {
                            error = "打印机缺纸";
                        }
                            mOnPrintinterface.failed(error);
                        }
                    });
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }.start();
    }

    public static void ThebankTransfer2(PosFuncs posFuncs,
                                        String time,
                                        String make_type,
                                        String runningwaterNo,
                                        String noName,
                                        String cardNo,
                                        String singusername,
                                        String singNo,
                                        String paymoney,
                                        String bitmap64code,
                                        onPrintinterface mOnPrintinterface) {
        new Thread() {
            @Override
            public void run() {
                try {
                    posFuncs.printerClearBuffer();
                    posFuncs.printerAppendLargeTextAlignCenter("惠农金服便利店");
                    posFuncs.printerAppendLargeTextAlignCenter("助农取款服务点通用凭证");
                    posFuncs.printerAppendTextline("交易时间 :" + time);
                    posFuncs.printerAppendTextline("设备号 :" + SPStaticUtils.getString("DeviceNum"));
                    posFuncs.printerAppendTextline("凭证序号 :" + SPStaticUtils.getInt("ccsno", 1));
                    posFuncs.printerAppendTextline("流水号 :" + runningwaterNo);
                    posFuncs.printerAppendTextline("客户经理 :" + SPStaticUtils.getString("ManagerNum"));
                    posFuncs.printerAppendTextline("交易名称 :" + make_type);
                    posFuncs.printerAppendTextline("账户名称 :" + "*" + noName.substring(1));
                    posFuncs.printerAppendTextline("卡号 :" + cardNo.substring(0, cardNo.length() - 5) + "****" + cardNo.substring(cardNo.length() - 1));

                    posFuncs.printerAppendTextline("转入户名 :" + "*" + singusername.substring(1));
                    posFuncs.printerAppendTextline("转入（卡）账号 :");
                    posFuncs.printerAppendTextline(singNo.substring(0, singNo.length() - 5) + "****" + singNo.substring(singNo.length() - 1));
                    posFuncs.printerAppendTextline("交易金额 :" + paymoney);

                    Bitmap bitmap = null;
                    try {
                        byte[] bitmapByte = Base64.decode(bitmap64code, Base64.DEFAULT);
                        bitmap = BitmapFactory.decodeByteArray(bitmapByte, 0, bitmapByte.length);
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                    posFuncs.printerAppendBitmap(scaleBitmap(bitmap));

                    posFuncs.printerAppendTextline("本人已确认银行打印记录正确无误");
                    posFuncs.printerAppendTextline("");
                    posFuncs.printerAppendTextline("客户签字确认 :");
                    posFuncs.printerAppendTextline("");
                    posFuncs.printerAppendTextline("                  ---客户留存---");
                    posFuncs.printerAppendTextline("");
                    posFuncs.printerAppendTextline("经办人员 :");
                    posFuncs.printerAppendTextline("");
                    posFuncs.printerAppendTextline("");
                    posFuncs.printerAppendTextline("");
                    posFuncs.printerAppendTextline("");
                    posFuncs.printerAppendTextline("");
                    posFuncs.startPrint(new PosCallbacks.PrintCallbacaks() {
                        @Override
                        public void onSuccess() {
                            mOnPrintinterface.success("打印成功");
                        }

                        @Override
                        public void onFailed(String error) {
                            if (error.equals("Lack Paper")) {
                                error = "打印机缺纸";
                            }
                            mOnPrintinterface.failed(error);
                        }
                    });
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }.start();
    }

    /**
     * 打印挂失
     *
     * @param posFuncs
     */

    public static void PrintSell(PosFuncs posFuncs,
                                 String time,
                                 String runningwaterNo,
                                 String make_type,
                                 String noName,
                                 String cardNo,
                                 String bitmap64code
            , onPrintinterface mOnPrintinterface) {
        new Thread(new Runnable() {
            @Override
            public void run() {
                posFuncs.printerClearBuffer();
                posFuncs.printerAppendLargeTextAlignCenter("惠农金服便利店");
                posFuncs.printerAppendLargeTextAlignCenter("助农取款服务点通用凭证");
                posFuncs.printerAppendTextline("交易时间 :" + time);
                posFuncs.printerAppendTextline("设备号 :" + SPStaticUtils.getString("DeviceNum"));
                posFuncs.printerAppendTextline("凭证序号 :" + SPStaticUtils.getInt("ccsno", 1));

                posFuncs.printerAppendTextline("流水号 :" + runningwaterNo);
                posFuncs.printerAppendTextline("客户经理 :" + SPStaticUtils.getString("ManagerNum"));
                posFuncs.printerAppendTextline("交易名称 :" + make_type);
                posFuncs.printerAppendTextline("账户名称 :" + noName);
                posFuncs.printerAppendTextline("卡号 :" + cardNo);
                Bitmap bitmap = null;
                try {
                    byte[] bitmapByte = Base64.decode(bitmap64code, Base64.DEFAULT);
                    bitmap = BitmapFactory.decodeByteArray(bitmapByte, 0, bitmapByte.length);
                } catch (Exception e) {
                    e.printStackTrace();
                }
                posFuncs.printerAppendBitmap(scaleBitmap(bitmap));

                posFuncs.printerAppendTextline("本人已确认银行打印记录正确无误");
                posFuncs.printerAppendTextline("");
                posFuncs.printerAppendTextline("客户签字确认 :");
                posFuncs.printerAppendTextline("");
                posFuncs.printerAppendTextline("                  ---客户留存---");
                posFuncs.printerAppendTextline("");
                posFuncs.printerAppendTextline("经办人员 :");
                posFuncs.printerAppendTextline("");
                posFuncs.printerAppendTextline("");
                posFuncs.printerAppendTextline("");
                posFuncs.printerAppendTextline("");
                posFuncs.printerAppendTextline("");
                posFuncs.startPrint(new PosCallbacks.PrintCallbacaks() {
                    @Override
                    public void onSuccess() {
                        mOnPrintinterface.success("打印成功");
                    }

                    @Override
                    public void onFailed(String error) {
                        if (error.equals("Lack Paper")) {
                            error = "打印机缺纸";
                        }
                        mOnPrintinterface.failed(error);
                    }
                });
            }
        }).start();
    }

    public static void PrintSell2(PosFuncs posFuncs,
                                  String time,
                                  String runningwaterNo,
                                  String make_type,
                                  String noName,
                                  String cardNo,
                                  String bitmap64code, onPrintinterface mOnPrintinterface) {
        new Thread(new Runnable() {
            @Override
            public void run() {
                posFuncs.printerClearBuffer();
                posFuncs.printerAppendLargeTextAlignCenter("惠农金服便利店");
                posFuncs.printerAppendLargeTextAlignCenter("助农取款服务点通用凭证");
                posFuncs.printerAppendTextline("交易时间 :" + time);
                posFuncs.printerAppendTextline("设备号 :" + SPStaticUtils.getString("DeviceNum"));
                posFuncs.printerAppendTextline("凭证序号 :" + SPStaticUtils.getInt("ccsno", 1));

                posFuncs.printerAppendTextline("流水号 :" + runningwaterNo);
                posFuncs.printerAppendTextline("客户经理 :" + SPStaticUtils.getString("ManagerNum"));
                posFuncs.printerAppendTextline("交易名称 :" + make_type);
                posFuncs.printerAppendTextline("账户名称 :" + "*" + noName.substring(1));
                posFuncs.printerAppendTextline("卡号 :" + cardNo.substring(0, cardNo.length() - 5) + "****" + cardNo.substring(cardNo.length() - 1));

                Bitmap bitmap = null;
                try {
                    byte[] bitmapByte = Base64.decode(bitmap64code, Base64.DEFAULT);
                    bitmap = BitmapFactory.decodeByteArray(bitmapByte, 0, bitmapByte.length);
                } catch (Exception e) {
                    e.printStackTrace();
                }
                posFuncs.printerAppendBitmap(scaleBitmap(bitmap));

                posFuncs.printerAppendTextline("本人已确认银行打印记录正确无误");
                posFuncs.printerAppendTextline("");
                posFuncs.printerAppendTextline("客户签字确认 :");
                posFuncs.printerAppendTextline("");
                posFuncs.printerAppendTextline("                  ---客户留存---");
                posFuncs.printerAppendTextline("");
                posFuncs.printerAppendTextline("经办人员 :");
                posFuncs.printerAppendTextline("");
                posFuncs.printerAppendTextline("");
                posFuncs.printerAppendTextline("");
                posFuncs.printerAppendTextline("");
                posFuncs.printerAppendTextline("");
                posFuncs.startPrint(new PosCallbacks.PrintCallbacaks() {
                    @Override
                    public void onSuccess() {
                        mOnPrintinterface.success("打印成功");
                    }

                    @Override
                    public void onFailed(String error)
                    { if (error.equals("Lack Paper")) {
                        error = "打印机缺纸";
                    }
                        mOnPrintinterface.failed(error);
                    }
                });
            }
        }).start();
    }

    /**
     * 打印子账户信息
     *
     * @param posFuncs
     * @param i        打印的第几个
     * @param zzhBeans bean 数据
     */
    public static void PrintZZH(PosFuncs posFuncs,
                                final int i,
                                List<ZzhBean> zzhBeans,
                                onPrintinterface mOnPrintinterface) {
        if (zzhBeans.size() > 0) {
            new Thread() {
                @Override
                public void run() {
                    super.run();
                    posFuncs.printerClearBuffer();
                    if (i == 0) {
                        all_num = 0;
                        posFuncs.printerAppendLargeTextAlignCenter("子账户明细");
                    }
                    //这个地方的打印信息自己写一下
                    posFuncs.printerAppendTextline("序号:" + GetMoneyLvUtils.getNum(i + 1 + ""));
                    posFuncs.printerAppendTextline("笔号:" + zzhBeans.get(i).getFS_SEQ_NO().trim());
                    posFuncs.printerAppendTextline("产品名称:" + zzhBeans.get(i).getSA_PDP_NAME().trim());
                    posFuncs.printerAppendTextline("币种:" + GetMoneyLvUtils.getZzhMoneyType(zzhBeans.get(i).getFS_CURR_COD()));
                    if (zzhBeans.get(i).getFS_OPAC_AMT().trim().equals("000000000000000")) {
                        posFuncs.printerAppendTextline("开户金额:0.00");
                    } else {
                        posFuncs.printerAppendTextline("开户金额:" + GetMoneyLvUtils.getMoney(zzhBeans.get(i).getFS_OPAC_AMT()));
                    }

                    if (zzhBeans.get(i).getFS_ACCT_BAL().trim().equals("000000000000000")) {
                        posFuncs.printerAppendTextline("账户余额:0.00");
                    } else {
                        posFuncs.printerAppendTextline("账户余额:" + GetMoneyLvUtils.getMoney(zzhBeans.get(i).getFS_ACCT_BAL()));
                    }

                    //到期日期
                    if (zzhBeans.get(i).getFS_DUE_DT().trim().equals("")) {
                        posFuncs.printerAppendTextline("到期日期:——");
                    } else {
                        posFuncs.printerAppendTextline("到期日期:" + zzhBeans.get(i).getFS_DUE_DT().trim());
                    }
                    //自动转存
                    if (zzhBeans.get(i).getFS_MNG_FLG().equals("1")) {
                        posFuncs.printerAppendTextline("自动转存:自动转存");
                    } else {
                        posFuncs.printerAppendTextline("自动转存:非自动转存");
                    }
                    //利率
//
                    posFuncs.printerAppendTextline("利率:" + GetMoneyLvUtils.getLv(zzhBeans.get(i).getFS_INTR()));


//账户状态
                    String type = zzhBeans.get(i).getFS_ACCT_STS();

                    if (type.equals("0")) {
                        posFuncs.printerAppendTextline("账户状态:正常");
                    } else if (type.equals("1")) {
                        posFuncs.printerAppendTextline("账户状态:销户");
                    } else if (type.equals("2")) {
                        posFuncs.printerAppendTextline("账户状态:没收");
                    } else if (type.equals("3")) {
                        posFuncs.printerAppendTextline("账户状态:上缴");
                    } else if (type.equals("4")) {
                        posFuncs.printerAppendTextline("账户状态:存单存折标志");
                    } else if (type.equals("5")) {
                        posFuncs.printerAppendTextline("账户状态:挂出");
                    } else if (type.equals("6")) {
                        posFuncs.printerAppendTextline("账户状态:冲正");
                    } else if (type.equals("7")) {
                        posFuncs.printerAppendTextline("账户状态:移除账户");
                    }
                    posFuncs.printerAppendTextline("");

                    if (i == zzhBeans.size() - 1) {
                        posFuncs.printerAppendTextline("");
                        posFuncs.printerAppendTextline("");
                        posFuncs.printerAppendTextline("");
                        posFuncs.printerAppendTextline("");
                        posFuncs.printerAppendTextline("");
                    }
                    posFuncs.startPrint(new PosCallbacks.PrintCallbacaks() {
                        @Override
                        public void onSuccess() {
                            if (all_num == zzhBeans.size() - 1) {
                                mOnPrintinterface.success("打印成功");
                            } else {
                                all_num++;
                                PrintZZH(posFuncs, all_num, zzhBeans, mOnPrintinterface);
                            }

                        }

                        @Override
                        public void onFailed(String error) {

                            if (error.equals("Lack Paper")) {
                                error = "打印机缺纸";
                            }

                            mOnPrintinterface.failed(error);
                        }
                    });
                }
            }.start();
        } else {
            mOnPrintinterface.failed("无数据");
        }

    }

    /**
     * @param posFuncs
     * @param i                打印的第几个
     * @param rateInfoBeans
     * @param onPrintinterface
     */
    public static void printLl(PosFuncs posFuncs,
                               final int i,
                               List<LlBean.RateInfoBean> rateInfoBeans,
                               onPrintinterface onPrintinterface) {

        if (rateInfoBeans.size() > 0) {
            new Thread(new Runnable() {
                @Override
                public void run() {
                    posFuncs.printerClearBuffer();
                    if (i == 0) {
                        all_num = 0;
                        posFuncs.printerAppendLargeTextAlignCenter("利率查询");
                        posFuncs.printerAppendTextline("");
                    }
                    posFuncs.printerAppendTextline(rateInfoBeans.get(i).getRateDesc().trim());
                    posFuncs.printerAppendTextline("生效日期:" + rateInfoBeans.get(i).getAvtDate());
                    String text1 = rateInfoBeans.get(i).getRate1().substring(2);

                    String llfont = text1.substring(0, 1);

                    String llqueen = text1.substring(1).replaceAll("0+$", "");
                    posFuncs.printerAppendTextline("币种:人民币");
                    posFuncs.printerAppendTextline("利率:" + llfont + "." + llqueen + "%");
                    posFuncs.printerAppendTextline("");
                    if (i == rateInfoBeans.size() - 1) {
                        posFuncs.printerAppendTextline("");
                        posFuncs.printerAppendTextline("");
                        posFuncs.printerAppendTextline("");
                        posFuncs.printerAppendTextline("");
                        posFuncs.printerAppendTextline("");
                    }
                    posFuncs.startPrint(new PosCallbacks.PrintCallbacaks() {
                        @Override
                        public void onSuccess() {
                            if (all_num == rateInfoBeans.size() - 1) {
                                onPrintinterface.success("打印成功");
                            } else {
                                all_num++;
                                printLl(posFuncs, all_num, rateInfoBeans, onPrintinterface);
                            }
                        }

                        @Override
                        public void onFailed(String error) {
                            if (error.equals("Lack Paper")) {
                                error = "打印机缺纸";
                            }
                            onPrintinterface.failed(error);
                        }
                    });

                }
            }).start();
        }
    }

    /**
     * 活期明细打印
     *
     * @param posFuncs
     * @param i        打印的第几个
     * @param hqBeans  bean 数据
     */
    public static void PrintHQMX(PosFuncs posFuncs,
                                 final int i,
                                 List<HqBean> hqBeans,
                                 onPrintinterface mOnPrintinterface) {
        if (hqBeans.size() > 0) {
            new Thread() {
                @Override
                public void run() {
                    super.run();
                    posFuncs.printerClearBuffer();
                    if (i == 0) {
                        all_num = 0;
                        posFuncs.printerAppendLargeTextAlignCenter("活期明细查询");
                    }
                    posFuncs.printerAppendTextline("序号:" + GetMoneyLvUtils.getNum(i + 1 + ""));
                    posFuncs.printerAppendTextline("交易时间:" + GetMoneyLvUtils.gettime(hqBeans.get(i).getTX_DT() + hqBeans.get(i).getTX_TM()));
                    //交易金额 CR +  DR-
                    if (hqBeans.get(i).getCR_AMT().equals("000000000000000")) {
                        posFuncs.printerAppendTextline("交易金额: -" + GetMoneyLvUtils.getMoney(hqBeans.get(i).getDR_AMT()));
                    } else {
                        posFuncs.printerAppendTextline("交易金额: +" + GetMoneyLvUtils.getMoney(hqBeans.get(i).getCR_AMT()));
                    }

                    posFuncs.printerAppendTextline("余额:" + GetMoneyLvUtils.getMoney(hqBeans.get(i).getDDP_ACCT_BAL()));
                    posFuncs.printerAppendTextline("币种:" + GetMoneyLvUtils.getMoneyType(hqBeans.get(i).getCURR_COD()));
                    posFuncs.printerAppendTextline("备注:" + hqBeans.get(i).getRMRK().trim());
                    posFuncs.printerAppendTextline("");
                    if (i == hqBeans.size() - 1) {
                        posFuncs.printerAppendTextline("");
                        posFuncs.printerAppendTextline("");
                        posFuncs.printerAppendTextline("");
                        posFuncs.printerAppendTextline("");
                        posFuncs.printerAppendTextline("");
                    }
                    posFuncs.startPrint(new PosCallbacks.PrintCallbacaks() {
                        @Override
                        public void onSuccess() {
                            if (all_num == hqBeans.size() - 1) {
                                mOnPrintinterface.success("打印成功");
                            } else {
                                all_num++;
                                PrintHQMX(posFuncs, all_num, hqBeans, mOnPrintinterface);
                            }

                        }

                        @Override
                        public void onFailed(String error) {
                            if (error.equals("Lack Paper")) {
                                error = "打印机缺纸";
                            }
                            mOnPrintinterface.failed(error);
                        }
                    });
                }
            }.start();
        } else {
        }

    }

    /**
     * 定期明细打印
     *
     * @param posFuncs
     * @param i        打印的第几个
     * @param dqBeans  bean 数据
     */
    public static void PrintDQMX(PosFuncs posFuncs,
                                 final int i,
                                 List<DqBean> dqBeans,
                                 onPrintinterface mOnPrintinterface) {
        if (dqBeans.size() > 0) {
            new Thread() {
                @Override
                public void run() {
                    super.run();
                    posFuncs.printerClearBuffer();
                    if (i == 0) {
                        all_num = 0;
                        posFuncs.printerAppendLargeTextAlignCenter("定期明细查询");
                    }
                    posFuncs.printerAppendTextline("序号 :" + (i + 1));
                    posFuncs.printerAppendTextline("笔号 :" + dqBeans.get(i).getVOL_NO());
                    posFuncs.printerAppendTextline("产品名称 :" + dqBeans.get(i).getPD_NAME().trim());
                    posFuncs.printerAppendTextline("交易金额 :" + GetMoneyLvUtils.getMoney(dqBeans.get(i).getTX_AMT()));
                    posFuncs.printerAppendTextline("利息 :" + GetMoneyLvUtils.getMoney(dqBeans.get(i).getTAX_INT_AMT()));
                    if (dqBeans.get(i).getDR_CR_COD().equals("D")) {
                        posFuncs.printerAppendTextline("借/贷 :" + "借");
                    } else {
                        posFuncs.printerAppendTextline("借/贷 :" + "贷");
                    }
                    posFuncs.printerAppendTextline("账户余额 :" + GetMoneyLvUtils.getMoney(dqBeans.get(i).getACCT_BAL().trim()));
                    if (dqBeans.get(i).getPD_NAME().trim().contains("智能存")) {
                        posFuncs.printerAppendTextline("存期 : ——");
                    } else {
                        posFuncs.printerAppendTextline("存期 :" + dqBeans.get(i).getDEP_PRD().trim().replaceFirst("^0*", "") + "天");
                    }

                    posFuncs.printerAppendTextline("交易时间 :" + GetMoneyLvUtils.gettimeNohour(dqBeans.get(i).getWK_DATE()));
                    posFuncs.printerAppendTextline("账户状态 :" + GetMoneyLvUtils.getAccType(dqBeans.get(i).getACCT_STS().trim()));
                    posFuncs.printerAppendTextline("摘要 :" + dqBeans.get(i).getTD_DSCRP().trim());
                    posFuncs.printerAppendTextline("");
                    if (i == dqBeans.size() - 1) {
                        posFuncs.printerAppendTextline("");
                        posFuncs.printerAppendTextline("");
                        posFuncs.printerAppendTextline("");
                        posFuncs.printerAppendTextline("");
                        posFuncs.printerAppendTextline("");
                    }
                    posFuncs.startPrint(new PosCallbacks.PrintCallbacaks() {
                        @Override
                        public void onSuccess() {
                            if (all_num == dqBeans.size() - 1) {
                                mOnPrintinterface.success("打印成功");
                            } else {
                                all_num++;
                                PrintDQMX(posFuncs, all_num, dqBeans, mOnPrintinterface);
                            }

                        }

                        @Override
                        public void onFailed(String error) {

                            if (error.equals("Lack Paper")) {
                                error = "打印机缺纸";
                            }
                            mOnPrintinterface.failed(error);
                        }
                    });
                }
            }.start();
        } else {
        }

    }

    /**
     * 交易查询明细
     *
     * @param posFuncs
     * @param i
     * @param mOnPrintinterface
     */
    public static void PAllDeal(PosFuncs posFuncs,
                                final int i,
                                String STIME,
                                String ENDTIME,
                                String status,
                                List<AllDealBean> dqBeans,
                                onPrintinterface mOnPrintinterface) {
        new Thread(() -> {
            posFuncs.printerClearBuffer();
            if (i == 0) {
                all_num = 0;
                posFuncs.printerAppendLargeTextAlignCenter("本机交易明细查询");
                posFuncs.printerAppendLargeTextAlignCenter("交易类型 :" + status);
                posFuncs.printerAppendLargeTextAlignCenter("交易日期 :" + STIME);
                posFuncs.printerAppendLargeTextAlignCenter("交易时间 :" + ENDTIME);
            }
            posFuncs.printerAppendTextline("序号 :" + (i + 1));
            posFuncs.printerAppendTextline("交易名称 :" + dqBeans.get(i).getTranname().trim());

            if (dqBeans.get(i).getAcctno().trim().equals("")) {
                posFuncs.printerAppendTextline("交易账号 :" + "——");
            } else {
                posFuncs.printerAppendTextline("交易账号 :" + dqBeans.get(i).getAcctno().trim());
            }
            if (dqBeans.get(i).getTranam().equals("")) {
                posFuncs.printerAppendTextline("交易金额 :" + "——");

            } else {
                posFuncs.printerAppendTextline("交易金额 :" + GetMoneyLvUtils.getMoney(dqBeans.get(i).getTranam()));

            }

            if (dqBeans.get(i).getStatus().equals("S")) {
                posFuncs.printerAppendTextline("交易状态 :" + "正常交易");
            } else {
                posFuncs.printerAppendTextline("交易状态 :" + "异常交易");
            }
            posFuncs.printerAppendTextline("交易日期 :" + GetMoneyLvUtils.gettimeNohour(dqBeans.get(i).getTransDate()));
            posFuncs.printerAppendTextline("交易时间 :" + GetMoneyLvUtils.gettimeHour(dqBeans.get(i).getTransTime()));
            posFuncs.printerAppendTextline("");
            if (i == dqBeans.size() - 1) {
                posFuncs.printerAppendTextline("");
                posFuncs.printerAppendTextline("");
                posFuncs.printerAppendTextline("");
                posFuncs.printerAppendTextline("");
                posFuncs.printerAppendTextline("");
            }
            posFuncs.startPrint(new PosCallbacks.PrintCallbacaks() {
                @Override
                public void onSuccess() {
                    if (all_num == dqBeans.size() - 1) {
                        mOnPrintinterface.success("打印成功");
                    } else {
                        all_num++;
                        PAllDeal(posFuncs, all_num, STIME, ENDTIME, status, dqBeans, mOnPrintinterface);
                    }

                }

                @Override
                public void onFailed(String error)
                { if (error.equals("Lack Paper")) {
                    error = "打印机缺纸";
                }
                    mOnPrintinterface.failed(error);
                }
            });
        }).start();

    }

    /**
     * 汇总交易查询
     *
     * @param posFuncs
     * @param i
     * @param mOnPrintinterface
     */
    public static void PAllSTATDeal(PosFuncs posFuncs,
                                    final int i,
                                    String STIME,
                                    String ENDTIME,
                                    String status,
                                    List<StatisticsBean> dqBeans,
                                    onPrintinterface mOnPrintinterface) {
        new Thread(() -> {
            posFuncs.printerClearBuffer();
            if (i == 0) {
                all_num = 0;
                posFuncs.printerAppendLargeTextAlignCenter("本机汇总交易查询");
                posFuncs.printerAppendLargeTextAlignCenter("交易类型 :" + status);
                posFuncs.printerAppendLargeTextAlignCenter("交易日期 :" + STIME);
                posFuncs.printerAppendLargeTextAlignCenter("交易时间 :" + ENDTIME);
            }
            posFuncs.printerAppendTextline("序号 :" + (i + 1));
            posFuncs.printerAppendTextline("交易名称 :" + dqBeans.get(i).getTradename().trim());
            if (dqBeans.get(i).getTradeType().equals("S")) {
                posFuncs.printerAppendTextline("交易状态 :" + "正常交易");
            } else {
                posFuncs.printerAppendTextline("交易状态 :" + "异常交易");
            }

            posFuncs.printerAppendTextline("交易交易笔数 :" + dqBeans.get(i).getTransnum());

            if (dqBeans.get(i).getAmount() == null) {
                posFuncs.printerAppendTextline("交易金额 :" + "0.00");
            } else {
                if (dqBeans.get(i).getAmount().equals("")) {
                    posFuncs.printerAppendTextline("交易金额 :" + "0.00");
                } else {
                    posFuncs.printerAppendTextline("交易金额 :" + dqBeans.get(i).getAmount());
                }
            }
            posFuncs.printerAppendTextline("设备号 :" + dqBeans.get(i).getDevNum());


            posFuncs.printerAppendTextline("交易时间 :" + GetMoneyLvUtils.gettimeNohour(dqBeans.get(i).getStatisdate()));
            posFuncs.printerAppendTextline("");
            if (i == dqBeans.size() - 1) {
                posFuncs.printerAppendTextline("");
                posFuncs.printerAppendTextline("");
                posFuncs.printerAppendTextline("");
                posFuncs.printerAppendTextline("");
                posFuncs.printerAppendTextline("");
            }
            posFuncs.startPrint(new PosCallbacks.PrintCallbacaks() {
                @Override
                public void onSuccess() {
                    if (all_num == dqBeans.size() - 1) {
                        mOnPrintinterface.success("打印成功");
                    } else {
                        all_num++;
                        PAllSTATDeal(posFuncs, all_num, STIME, ENDTIME, status, dqBeans, mOnPrintinterface);
                    }

                }

                @Override
                public void onFailed(String error) {
                    if (error.equals("Lack Paper")) {
                        error = "打印机缺纸";
                    }
                    mOnPrintinterface.failed(error);
                }
            });
        }).start();

    }

    /**
     * 特殊业务
     *
     * @param posFuncs
     * @param i        打印的第几个
     * @param spbeans  bean 数据
     */
    public static void PrintSp(PosFuncs posFuncs,
                               final int i,
                               List<SpBean> spbeans,
                               onPrintinterface mOnPrintinterface) {
        if (spbeans.size() > 0) {
            new Thread() {
                @Override
                public void run() {
                    super.run();
                    posFuncs.printerClearBuffer();
                    if (i == 0) {
                        all_num = 0;
                        posFuncs.printerAppendLargeTextAlignCenter("特色业务收益查询");
                    }
                    posFuncs.printerAppendTextline("序号 :" + (i + 1));
                    posFuncs.printerAppendTextline("理财序号 :" + spbeans.get(i).getSerialNo());
                    posFuncs.printerAppendTextline("账户状态 :" + GetMoneyLvUtils.getSpType(spbeans.get(i).getStatus()));
                    posFuncs.printerAppendTextline("起息日期 :" + GetMoneyLvUtils.gettimeNohour(spbeans.get(i).getIntrestStartDate()));
                    posFuncs.printerAppendTextline("理财金额 :￥" + GetMoneyLvUtils.getMoney(spbeans.get(i).getDetailFinanceBalance()));
                    posFuncs.printerAppendTextline("计息金额 :￥" + GetMoneyLvUtils.getMoney(spbeans.get(i).getIntrestAmount()));
                    posFuncs.printerAppendTextline("理财积数 :￥" + GetMoneyLvUtils.getMoney(spbeans.get(i).getBalanceAmount()));
                    posFuncs.printerAppendTextline("试算利率 :" + GetMoneyLvUtils.getLv(spbeans.get(i).getCalculateRate()));
                    posFuncs.printerAppendTextline("试算利息 :￥" + GetMoneyLvUtils.getMoney(spbeans.get(i).getCalculateInt()));
                    posFuncs.printerAppendTextline("结息日期 :" + GetMoneyLvUtils.gettimeNohour(spbeans.get(i).getIntrestEndDate()));
                    posFuncs.printerAppendTextline("入账日期 :" + GetMoneyLvUtils.gettimeNohour(spbeans.get(i).getAcctDate()));
                    posFuncs.printerAppendTextline("执行利率 :" + GetMoneyLvUtils.getLv(spbeans.get(i).getIntrestRate()));
                    posFuncs.printerAppendTextline("利息 :￥" + GetMoneyLvUtils.getMoney(spbeans.get(i).getIntrest()));
                    posFuncs.printerAppendTextline("");
                    posFuncs.printerAppendTextline("");
                    if (i == spbeans.size() - 1) {
                        posFuncs.printerAppendTextline("");
                        posFuncs.printerAppendTextline("");
                        posFuncs.printerAppendTextline("");
                        posFuncs.printerAppendTextline("");
                        posFuncs.printerAppendTextline("");
                    }

                    posFuncs.startPrint(new PosCallbacks.PrintCallbacaks() {
                        @Override
                        public void onSuccess() {
                            if (all_num == spbeans.size() - 1) {
                                mOnPrintinterface.success("打印成功");
                            } else {
                                all_num++;
                                PrintSp(posFuncs, all_num, spbeans, mOnPrintinterface);
                            }

                        }

                        @Override
                        public void onFailed(String error) {

                            if (error.equals("Lack Paper")) {
                                error = "打印机缺纸";
                            }
                            mOnPrintinterface.failed(error);
                        }
                    });
                }
            }.start();
        } else {
        }

    }


    /**
     * 缩小bipmap
     *
     * @param origin
     * @return
     */
    private static Bitmap scaleBitmap(Bitmap origin) {
        if (origin == null) {
            return null;
        }
        int width = origin.getWidth();
        int height = origin.getHeight();
        Matrix matrix = new Matrix();
        matrix.preScale((float) 0.5, (float) 0.5);
        Bitmap newBM = Bitmap.createBitmap(origin, 0, 0, width, height, matrix, false);
        if (newBM.equals(origin)) {
            return newBM;
        }
        origin.recycle();
        return newBM;
    }

    public interface onPrintinterface {
        void success(String success);

        void failed(String error);
    }

}
